<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/3/22
 * Time: 1:08
 */
namespace app\admin\model\getdatas\bind;
use app\admin\model\getdatas\Mydata;
use think\facade\Db;

class Lianbiao extends Mydata
{
    public $data = [];
    public function getPidAll($value=0){

    }

    /**获取模块的下级
     * @param string $table
     * @param array $where
     * @return Db
     */
    public static function getMokuaiChild($table='column',$where=[]){
        $obj = new Lianbiao();
        return $obj->getChenChild($table,0,0,$where);
    }
    public function getChenChild($table='column',$pid=0,$chengji=0,$where=[]){
        $data = Db::name(getTable($table));
        if($where){
            $data = $data->where($where);
        }
        $data = $data->where('pid',$pid);
        $data = $data->where('delete_time',0)
            ->order('sort desc')
            ->where('status',1)
            ->select()->toArray();
        foreach ($data as $key=>$value){
            $value['cheng'] = $chengji;
            $value['child'] = $this->getChenChild($table,$value['id'],$chengji+1,$where);
            $data[$key] = $value;
        }
        return $data;
    }
}